home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Utilities / Winter Shell 1.0d2 / Source / Libraries / FileLib / FileLib.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-01-17  |  6.5 KB  |  146 lines  |  [TEXT/KAHL]

  1. #pragma once
  2.  
  3. #define FILE_VERSION        (1)    /* version of File Library; incremented
  4.                                             for every change to the FileType structure */
  5. #define FILE_CLOSED        (0)    /* reference number of closed files */
  6. #define FILE_BUFSIZ        (512)    /* size of input/output buffers */
  7.  
  8. #define kFolderBit        (4)    /* bit in ioFlAttrib */
  9.  
  10. /* Bits in the fdFlags field of the FInfo record. These don't seem to have
  11.     been defined anywhere in the interface files, even though they're
  12.     described in IM VI. */
  13.  
  14. #define fIsAlias        (1<<15)    /* The file is an alias file. Reserved for 
  15.                                             directories in which case, set to 0. */
  16. #define fIsInvisible    (1<<14)    /* The file or directory is invisible from the 
  17.                                             Finder and from the Standard File Package
  18.                                             dialog boxes. */
  19. /*#define fHasBundle    (1<<13)    /* The file contains a bundle resource.
  20.                                             Reserved for directories—in which case,
  21.                                             set to 0. */
  22. #define fNameLocked    (1<<12)    /* The file or directory can’t be renamed from
  23.                                             the Finder and the icon cannot be changed. */
  24. #define fIsStationery (1<<11)/* The file is a stationery pad. Reserved for 
  25.                                             directories in which case, set to 0. */
  26. #define fHasCustomIcon (1<<10)/* The file or directory contains a customized
  27.                                             icon. */
  28. #define fReserved9    (1<<9)    /* Reserved; set to 0. */
  29. #define fHasBeenInited (1<<8)    /*    The Finder has recorded information
  30.                                             from the file’s bundle into the desktop
  31.                                             database and given the file or folder a
  32.                                             position on the desktop. */
  33. #define fHasNoINITS    (1<<7)    /* The file contains no 'INIT' resources; set
  34.                                             to 0.    Reserved for directories; set to 0. */
  35. #define fIsShared        (1<<6)    /* The application is available to multiple
  36.                                             users. Defined only for applications;
  37.                                             otherwise, set to 0. */
  38. #define fReserved5    (1<<5)    /* Reserved; set to 0. */
  39. #define fReserved4    (1<<4)    /*    Reserved; set to 0. */
  40. #define fColorBit3    (1<<3)    /* Three bits of color coding. */
  41. #define fColorBit2    (1<<2)    /* Three bits of color coding. */
  42. #define fColorBit1    (1<<1)    /* Three bits of color coding. */
  43. #define fReserved0    (1<<0)    /* Reserved; set to 0.*/
  44.  
  45. typedef short            FileVolType;    /* volume reference number */
  46. typedef short            FileRefType;    /* file reference number */
  47. typedef long            FileDirType;    /* directory reference number */
  48. typedef short            FileWDirType;    /* working directory reference number */
  49. typedef long            FilePosType;    /* position in a file */
  50. typedef short            FileSeekType;    /* for setting position in a file */
  51. typedef SignedByte    FilePermType;    /* access permission */
  52. typedef CStr31            FileNameType;    /* file name */
  53. typedef Str31            FilePNameType;    /* file name (pascal string) */
  54. typedef CStr255        FilePathType;    /* partial pathname */
  55. typedef Str255            FilePPathType;    /* partial pathname (pascal string) */
  56.  
  57. /* Structure describing a file on the Macintosh. When possible, you should
  58.     use the functions provided in the File Library to manipulate files,
  59.     passing a pointer to this structure as a parameter. This should
  60.     help simplify keeping track of files, which otherwise may become
  61.     totally confusing. You should avoid directly accessing any of the
  62.     elements of a FileType structure. The first three fields of a FileType
  63.     structure are similar to the three fields of an FSSpec structure,
  64.     except that the name field of an FSSpec structure is of type Str63,
  65.     while the pnm field of a FileType structure is of type Str31 (typedef'd
  66.     to FilePNameType). */
  67. typedef struct {
  68.     FileVolType        vol;        /* volume reference number */
  69.     FileDirType        dir;        /* parent directory ID */
  70.     FilePNameType    pnm;        /* name in Pascal string format */
  71.     FileNameType    cnm;        /* name in C string format */
  72.     FileRefType        ref;        /* reference number of open file */
  73.     Boolean            lock:1;    /* if true, range locking is done before read/write */
  74.     Boolean            verify:1;/* if true, writes are verified */
  75. } FileType, *FilePtr, **FileHandle;
  76.  
  77. Boolean FileValid(FileType *fp);
  78.  
  79. void FileResolve(FileType *fp);
  80.  
  81. const char *FileName(FileType *fp);
  82. const StringPtr FilePName(FileType *fp);
  83. void FileNameSet(FileType *fp, const FileNameType name);
  84. void FilePNameSet(FileType *fp, const FilePNameType name);
  85. void FileToFSSpec(FileType *fp, FSSpec *spec);
  86.  
  87. void FileSet(FileType *fp, FileVolType vol, FileDirType dir, const FileNameType name);
  88. void FileSetWD(FileType *fp, FileWDirType wdref, const FileNameType name);
  89. void FileSetRef(FileType *fp, FileRefType ref);
  90. void FileSetFSSpec(FileType *fp, const FSSpec *spec);
  91. void FileSetSys(FileType *fp, const FileNameType name);
  92. void FileSetPref(FileType *fp, const FileNameType name);
  93. void FileSetExtension(FileType *fp, const FileNameType name);
  94. void FileSetTemp(FileType *fp);
  95.  
  96. void FileClone(FileType *src, FileType *dst);
  97.  
  98. void FileOpen(FileType *fp, FilePermType permission);
  99. void FileOpenRes(FileType *fp, FilePermType permission);
  100. void FileClose(FileType *fp);
  101.  
  102. FilePosType FilePosition(FileType *fp);
  103. void FileSeek(FileType *fp, FileSeekType seek, FilePosType position);
  104. FilePosType FileSize(FileType *fp);
  105. void FileResize(FileType *fp, FilePosType size);
  106.  
  107. void FileAutoLockSet(FileType *fp, Boolean lock);
  108. void FileVerifySet(FileType *fp, Boolean verify);
  109. void FileRangeLock(FileType *fp, FilePosType count, FilePosType pos);
  110. void FileRangeUnlock(FileType *fp, FilePosType count, FilePosType pos);
  111.  
  112. FilePosType FileRead(FileType *fp, FilePosType count, void *buffer);
  113. void FileWrite(FileType *fp, FilePosType count, const void *buffer);
  114. Boolean FileReadChar(FileType *fp, char *c);
  115. void FileWriteChar(FileType *fp, char c);
  116. FilePosType FileReadStr(FileType *fp, FilePosType count, char *str, char stop);
  117. FilePosType FileReadLine(FileType *fp, FilePosType count, char *line);
  118. void FileWriteStr(FileType *fp, const char *str);
  119.  
  120. void FileFlush(FileType *fp);
  121.  
  122. OSType FileCreator(FileType *fp);
  123. OSType FileTypeGet(FileType *fp);
  124. void FileInfoGet(FileType *fp, FInfo *info);
  125. void FileInfoSet(FileType *fp, FInfo *info);
  126. void FileCatalog(FileType *fp, CInfoPBRec *pb);
  127. void FileCatalogSet(FileType *fp, CInfoPBRec *pb);
  128.  
  129. void FileCreate(FileType *fp, OSType creator, OSType type);
  130. void FileDelete(FileType *fp);
  131. void FileErase(FileType *fp);
  132. void FileRename(FileType *fp, const FileNameType newname);
  133.  
  134. void FileDirID(FileType *fp);
  135. Boolean FilesAreSame(FileType *a, FileType *b);
  136. Boolean FileExists(FileType *fp);
  137. void FileUniqueInList(FileNameType name, ...);
  138. void FileUnique(FileType *fp);
  139.  
  140. void FileCopyFork(FileType *src, FileType *dst);
  141. void FileCopyData(FileType *src, FileType *dst);
  142. void FileCopyRes(FileType *src, FileType *dst);
  143. void FileCopy(FileType *src, FileType *dst);
  144. void FileMove(FileType *src, FileType *dst);
  145. void FileExchange(FileType *f1, FileType *f2);
  146.